﻿using Prism.Events;
using System;

namespace MaterialTypeRecognition.Shell.Utils
{
    /// <summary>
    /// 定义事件参数
    /// </summary>
    public class InBoundEventArgs
    {
        public bool Succeess { get; set; }

        public string? Message { get; set; }

        public string Sfc { get; set; }

        public InBoundEventArgs(bool succeess, string? message, string sfc)
        {
            Sfc = sfc;
            Succeess = succeess;
            Message = message;
        }
    }

    // 定义事件
    public class InBoundEvent : PubSubEvent<InBoundEventArgs>
    {
    }

    public class InBoundSubscriber
    {
        public event EventHandler<InBoundEventArgs>? Inbound;

        // 构造函数注入 IEventAggregator
        public InBoundSubscriber(IEventAggregator eventAggregator)
        {
            // 订阅事件
            eventAggregator.GetEvent<InBoundEvent>().Subscribe(OnHandle);
        }

        // 事件处理方法
        private void OnHandle(InBoundEventArgs message)
        {
            Inbound?.Invoke(this, message);
        }
    }
}
